home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / 92052tar.gz / 920528.tar / global.h < prev    next >
C/C++ Source or Header  |  1992-05-28  |  6KB  |  228 lines

  1. /* @(#) $Header: global.h,v 1.16 92/05/28 13:50:14 deyke Exp $ */
  2.  
  3. #ifndef _GLOBAL_H
  4. #define _GLOBAL_H
  5.  
  6. /* Global definitions used by every source file.
  7.  * Some may be compiler dependent.
  8.  */
  9.  
  10. #if     defined(__TURBOC__) || defined(__STDC__) || defined(LATTICE)
  11. #define ANSIPROTO       1
  12. #else
  13. #define const
  14. #endif
  15.  
  16. #ifndef __ARGS
  17. #ifdef  ANSIPROTO
  18. #define __ARGS(x)       x
  19. #else
  20. #define __ARGS(x)       ()
  21. #endif
  22. #endif
  23.  
  24. #if     !defined(AMIGA) && (defined(LATTICE) || defined(MAC) || defined(__TURBOC__))
  25. /* These compilers require special open modes when reading binary files.
  26.  *
  27.  * "The single most brilliant design decision in all of UNIX was the
  28.  * choice of a SINGLE character as the end-of-line indicator" -- M. O'Dell
  29.  *
  30.  * "Whoever picked the end-of-line conventions for MS-DOS and the Macintosh
  31.  * should be shot!" -- P. Karn's corollary to O'Dell's declaration
  32.  */
  33. #define READ_BINARY     "rb"
  34. #define WRITE_BINARY    "wb"
  35. #define APPEND_BINARY   "ab+"
  36. #define READ_TEXT       "rt"
  37. #define WRITE_TEXT      "wt"
  38. #define APPEND_TEXT     "at+"
  39.  
  40. #else
  41.  
  42. #define READ_BINARY     "r"
  43. #define WRITE_BINARY    "w"
  44. #define APPEND_BINARY   "a+"
  45. #define READ_TEXT       "r"
  46. #define WRITE_TEXT      "w"
  47. #define APPEND_TEXT     "a+"
  48.  
  49. #endif
  50.  
  51. /* These two lines assume that your compiler's longs are 32 bits and
  52.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  53.  * but it doesn't matter if they're signed or unsigned.
  54.  */
  55. typedef int int32;              /* 32-bit signed integer */
  56. typedef unsigned short int16;   /* 16-bit unsigned integer */
  57. typedef unsigned char byte_t;   /*  8-bit unsigned integer */
  58. #define uchar(x) ((x) & 0xff)
  59. #define MAXINT16 65535          /* Largest 16-bit integer */
  60. #define MAXINT32 4294967295L    /* Largest 32-bit integer */
  61.  
  62. #define HASHMOD 7               /* Modulus used by hash_ip() function */
  63.  
  64. /* The "interrupt" keyword is non-standard, so make it configurable */
  65. #if     defined(__TURBOC__) && defined(MSDOS)
  66. #define INTERRUPT       void interrupt
  67. #else
  68. #define INTERRUPT       void
  69. #endif
  70.  
  71. /* Note that these definitions are on by default if none of the Turbo-C style
  72.  * memory model definitions are on; this avoids having to change them when
  73.  * porting to 68K environments.
  74.  */
  75. #if     !defined(__TINY__) && !defined(__SMALL__) && !defined(__MEDIUM__)
  76. #define LARGEDATA       1
  77. #endif
  78.  
  79. #if     !defined(__TINY__) && !defined(__SMALL__) && !defined(__COMPACT__)
  80. #define LARGECODE       1
  81. #endif
  82.  
  83. /* Since not all compilers support structure assignment, the ASSIGN()
  84.  * macro is used. This controls how it's actually implemented.
  85.  */
  86. #ifdef  NOSTRUCTASSIGN  /* Version for old compilers that don't support it */
  87. #define ASSIGN(a,b)     memcpy((char *)&(a),(char *)&(b),sizeof(b));
  88. #else                   /* Version for compilers that do */
  89. #define ASSIGN(a,b)     ((a) = (b))
  90. #endif
  91.  
  92. /* Define null object pointer in case stdio.h isn't included */
  93. #ifndef NULL
  94. /* General purpose NULL pointer */
  95. #define NULL (void *)0
  96. #endif
  97. #define NULLCHAR (char *)0      /* Null character pointer */
  98. #define NULLCHARP (char **)0    /* Null character pointer pointer */
  99. #define NULLINT (int *)0        /* Null integer pointer */
  100. #define NULLFP   (int (*)())0   /* Null pointer to function returning int */
  101. #define NULLVFP  (void (*)())0  /* Null pointer to function returning void */
  102. #define NULLVIFP (INTERRUPT (*)())0
  103. #define NULLFILE (FILE *)0      /* Null file pointer */
  104.  
  105. /* standard boolean constants */
  106. #define FALSE 0
  107. #define TRUE 1
  108. #define NO 0
  109. #define YES 1
  110.  
  111. /* string equality shorthand */
  112. #define STREQ(x,y) (strcmp(x,y) == 0)
  113.  
  114. /* Extract a short from a long */
  115. #define hiword(x)       ((int16)((x) >> 16))
  116. #define loword(x)       ((int16)(x))
  117.  
  118. /* Extract a byte from a short */
  119. #define hibyte(x)       ((unsigned char)((x) >> 8))
  120. #define lobyte(x)       ((unsigned char)(x))
  121.  
  122. /* Extract nibbles from a byte */
  123. #define hinibble(x)     (((x) >> 4) & 0xf)
  124. #define lonibble(x)     ((x) & 0xf)
  125.  
  126. /* Various low-level and miscellaneous functions */
  127. int availmem __ARGS((void));
  128. void *callocw __ARGS((unsigned nelem,unsigned size));
  129. int dirps __ARGS((void));
  130. int getopt();
  131. int htoi __ARGS((char *));
  132. long htol __ARGS((char *));
  133. char *inbuf __ARGS((int16 port,char *buf,int16 cnt));
  134. int16 hash_ip __ARGS((int32 addr));
  135. int istate __ARGS((void));
  136. void log();
  137. int log2 __ARGS((int x));
  138. #define ltop(x) ((void *) (x))
  139. void *mallocw __ARGS((unsigned nb));
  140. int memcnt __ARGS((char *buf,char c,int size));
  141. char *outbuf __ARGS((int16 port,char *buf,int16 cnt));
  142. #define ptol(x) ((long) (x))
  143. void restore __ARGS((int));
  144. void rip __ARGS((char *));
  145. char *smsg __ARGS((char *msgs[],unsigned nmsgs,unsigned n));
  146. void stktrace __ARGS((void));
  147. #if     !defined __TURBOC__
  148. char *strdup();
  149. #endif
  150. int wildmat __ARGS((char *s,char *p,char **argv));
  151.  
  152. #include <stdlib.h>
  153. #include <string.h>
  154.  
  155. int stricmp __ARGS((char *s1, char *s2));
  156. int strnicmp __ARGS((char *s1, char *s2, size_t maxlen));
  157.  
  158. #ifdef  AZTEC
  159. #define rewind(fp)      fseek(fp,0L,0);
  160. #endif
  161.  
  162. #if     defined(__TURBOC__) && defined(MSDOS)
  163. #define movblock(so,ss,do,ds,c) movedata(ss,so,ds,do,c)
  164.  
  165. #else
  166.  
  167. /* General purpose function macros already defined in turbo C */
  168. #ifndef min
  169. #define min(x,y)        ((x)<(y)?(x):(y))       /* Lesser of two args */
  170. #endif
  171. #ifndef max
  172. #define max(x,y)        ((x)>(y)?(x):(y))       /* Greater of two args */
  173. #endif
  174. #ifdef  MSDOS
  175. #define MK_FP(seg,ofs)  ((void far *) \
  176.             (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  177. #endif
  178. #endif  /* __TURBOC __ */
  179.  
  180. #ifdef  AMIGA
  181. /* super kludge de WA3YMH */
  182. #ifndef fileno
  183. #include <stdio.h>
  184. #endif
  185. #define fclose(fp)      amiga_fclose(fp)
  186. extern int amiga_fclose __ARGS((FILE *));
  187. extern FILE *tmpfile __ARGS((void));
  188.  
  189. extern char *sys_errlist[];
  190. extern int errno;
  191. #endif
  192.  
  193. /* Externals used by getopt */
  194. extern int optind;
  195. extern char *optarg;
  196.  
  197. /* Threshold setting on available memory */
  198. extern int32 Memthresh;
  199.  
  200. /* System clock - count of ticks since startup */
  201. extern int32 Clock;
  202.  
  203. /* Various useful standard error messages */
  204. extern char Badhost[];
  205. extern char Nospace[];
  206. extern char Notval[];
  207. extern char *Hostname;
  208. extern char Version[];
  209.  
  210. /* Your system's end-of-line convention */
  211. extern char Eol[];
  212.  
  213. /* Your system's temp directory */
  214. extern char *Tmpdir;
  215.  
  216. extern void (*Gcollect[])();
  217.  
  218. struct asy;
  219. struct ax25_cb;
  220. struct iface;
  221. struct mbuf;
  222. struct usock;
  223.  
  224. extern int Debug;
  225. extern int Shortstatus;
  226.  
  227. #endif  /* _GLOBAL_H */
  228.